import {
    DIC
} from '@/const/dic'
export const pojoOption = {
    index:true,
    indexLabel:'序号',
    border: true,
    selection: false,
    menuBtn: true,
    addBtn:false,
    size: 'mini',
    cellBtn: false,
    editBtn: false,
    columnBtn:false,
    refreshBtn:false,
    delBtn: false,
    dicData: DIC,
    align: "center",
    menuWidth: 150,
    menuAlign: "center",
    column: [{
        label: "项目状态",
        prop: "status",
        slot: true
    },{
        label: "项目编码",
        prop: "number",
    },{
        label: "项目名称",
        prop: "name",
    },{
        label: "项目说明",
        prop: "description",
    },{
        label: "项目日期",
        prop: "startTime",
        slot: true,
    },{
        label: "创建人",
        prop: "updateName",
    },{
        label: "创建时间",
        prop: "updateTime",
    }]
};

export const maintenanceOption = {
    index:true,
    indexLabel:'序号',
    border: true,
    selection: false,
    menuBtn: true,
    addBtn:false,
    cellBtn: false,
    editBtn: false,
    size: 'mini',
    columnBtn:false,
    refreshBtn:false,
    delBtn: false,
    dicData: DIC,
    align: "center",
    menuWidth: 200,
    menuAlign: "center",
    column: [{
        label: "维保结果",
        prop: "maintenanceResults",
        slot: true
    },{
        label: "维保类型",
        prop: "maintenanceType",
        slot: true
    },{
        label: "维保单位",
        prop: "unit",
    },{
        label: "维护费用（元）",
        prop: "maintenanceCharge",
    },{
        label: "维保人",
        prop: "person",
    },{
        label: "维保时间",
        prop: "startTime",
        slot: true
    }
    ]
};

export const useOption = {
    index:true,
    indexLabel:'序号',
    border: true,
    selection: false,
    size: 'mini',
    menu: false,
    addBtn:false,
    cellBtn: false,
    editBtn: false,
    columnBtn:false,
    refreshBtn:false,
    delBtn: false,
    dicData: DIC,
    align: "center",
    menuWidth: 180,
    menuAlign: "center",
    column: [{
        label: "样品编码",
        prop: "idno",
    },{
        label: "样品名称",
        prop: "name",
    },{
        label: "检测编码",
        prop: "name",
    },{
        label: "检测项目",
        prop: "name",
    },{
        label: "检测结果",
        prop: "name",
    },{
        label: "时间",
        prop: "name",
    }
    ]
}; 

export const deviceDataOption = {
    index:true,
    indexLabel:'序号',
    border: true,
    selection: false,
    menuBtn: true,
    addBtn:false,
    size: 'mini',
    cellBtn: false,
    editBtn: false,
    columnBtn:false,
    refreshBtn:false,
    delBtn: false,
    dicData: DIC,
    align: "center",
    menuWidth: 150,
    menuAlign: "center",
    column: [{
        label: "新数据文件",
        prop: "fileOldName",
    },{
        label: "旧数据文件",
        prop: "fileNewName",
    },{
        label: "文件格式",
        prop: "fileSuffix",
    },{
        label: "文件路径",
        prop: "url",
    },
    ]
}; 
export const bandrOption = {
    index:true,
    indexLabel:'序号',
    border: true,
    selection: false,
    addBtn:false,
    cellBtn: false,
    editBtn: false,
    columnBtn:false,
    refreshBtn:false,
    delBtn: false,
    size: 'mini',
    dicData: DIC,
    align: "center",
    menuWidth: 180,
    menuAlign: "center",
    column: [{
        label: "审批单号",
        prop: "approvalNumber",
    },{
        label: "出库状态",
        prop: "borrowingStatus",
        slot: true,
    },{
        label: "仓库",
        prop: "warehouse",
        slot: true
    },{
        label: "借阅时间",
        prop: "name",
    },{
        label: "申请部门/人",
        prop: "departmentName",
        slot: true,
    },{
        label: "申请时间",
        prop: "insertTime",
    },{
        label: "出库人/时间",
        prop: "borrowingUserName",
        slot: true,
    },{
        label: "归库人/时间",
        prop: "returnUserName",
        slot: true,
    }
    ]
};
export function jsonToArray(nodes) {
    var r=[];
    if (Array.isArray(nodes)) {
      for (var i=0, l=nodes.length; i<l; i++) {
        r.push(nodes[i]); // 取每项数据放入一个新数组
        if (Array.isArray(nodes[i]["children"])&&nodes[i]["children"].length>0)
         // 若存在children则递归调用，把数据拼接到新数组中，并且删除该children
          r = r.concat(jsonToArray(nodes[i]["children"]));
            delete nodes[i]["children"]
      }
    } 
    return r;
}